﻿using HRMSystem.Models;
using HRMSystem.Wpf.BranchPages;
using HRMSystem.Wpf.DepartmentPages;
using HRMSystem.Wpf.WpfWindow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HRMSystem.Wpf.CompanyPages
{
    /// <summary>
    /// Interaction logic for viewPage.xaml
    /// </summary>
    public partial class ViewPage : Page
    {
        private static ViewPage instance;
        List<CompanyDetails> list, hoList;

        public ViewPage()
        {
            InitializeComponent();

           // list = DBServices.CompanyService.findCompanyDetails(Session.Manager.ID);
            list = DBServices.CompanyService.findCompanyDetails(1);
            //hoList = DBServices.CompanyService.findHeadOffice(list.ElementAt(0).CID);

            name.Text = list.ElementAt(0).NAME;
            regNo.Text = list.ElementAt(0).REG_NO;
            vision.Text = list.ElementAt(0).VISION;
            mission.Text = list.ElementAt(0).MISSION;
            cSDate.Text = list.ElementAt(0).START_DATE.Value.ToShortDateString();
            departmrnt.Text = list.ElementAt(0).DEPARTMENTNAME;

            if (hoList.ElementAt(0).HOADDRESS == null)
            {
                lbl_hOAddress.Visibility = Visibility.Hidden;
            }
            else
            {
                hOAddress.Text = hoList.ElementAt(0).HOADDRESS;
            }

            if (list.ElementAt(0).YOURADDRESS == null)
            {
                lbl_yBAddress.Visibility = Visibility.Hidden;
            }
            else
            {
                yBAddress.Text = list.ElementAt(0).YOURADDRESS;
            }
        }

        public static ViewPage Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ViewPage();
                }

                return instance;
            }
        }

        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            CompanyPage.Instance.ContentFrame.Content = EditPage.Instance;

        }


        private void Add_Click(object sender, RoutedEventArgs e)
        {
            CompanyPage.Instance.ContentFrame.Content = AddPage.Instance;

        }

        public static void NullInstance()
        {
            instance = new ViewPage();
        }

        private void Department_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.ContentFrame.Content = DepartmentPage.Instance;
        }

        private void Branch_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.ContentFrame.Content = BranchPage.Instance;
        }

        

    }
}
